package cn.tedu.test02;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class User {

    private Phone phone;

    public User(){
        System.out.println("User的构造方法执行了");
    }

    @PostConstruct
    //自定义初始化方法
    public void init(){
        System.out.println("User准备打电话了");
    }

    @Autowired //自动装配（自动布线），来进行属性注入
    public void setPhone(Phone phone){
        this.phone=phone;
        System.out.println("setter方法执行了");
    }

    @PreDestroy
    public void destroy(){
        System.out.println("User把手机扔了");
    }
}